package org.yunmai.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.yunmai.entity.SysRole;
import org.yunmai.vo.SysRoleVO;


import java.util.List;

/**
* @author Administrator
* @description 针对表【sys_role】的数据库操作Mapper
* @createDate 2025-06-03 19:47:53
* @Entity org.yunmai.entity.SysRole
*/
@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {

    @Select({
            "<script>",
            "SELECT ",
            "   id, ",
            "   role_name, ",
            "   role_code, ",
            "   description ",
            "FROM sys_role ",
            "WHERE 1=1 ",
            "<if test='keyword != null and keyword != \"\"'>",
            "   AND (role_name LIKE CONCAT('%', #{keyword}, '%') ",
            "   OR role_code LIKE CONCAT('%', #{keyword}, '%') ",
            "   OR description LIKE CONCAT('%', #{keyword}, '%')) ",
            "</if>",
            "ORDER BY id ",
            "LIMIT #{offset}, #{pageSize}",
            "</script>"
    })
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "roleName", column = "role_name"),
            @Result(property = "roleCode", column = "role_code"),
            @Result(property = "description", column = "description")
    })
    List<SysRoleVO> selectRolePage(@Param("offset") int offset, @Param("pageSize") int pageSize, @Param("keyword") String keyword);
}




